import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/login.vue'
import Register from '@/views/register.vue'
import Detail from '@/views/detail.vue'
import Layout from '@/views/layout.vue'

import Like from '@/views/second/like'
import Article from '@/views/second/article'
import Collect from '@/views/second/collect'
import User from '@/views/second/user'

Vue.use(VueRouter)
// - 首页（一级） layout
//       - 面经（二级）article
//       - 收藏（二级）collect
//       - 喜欢（二级）like
//       - 我的（二级）user
// - 文章详情页（一级） detail
// - 登录页 （一级） login
// - 注册页（一级） register
const router = new VueRouter({
  routes: [
    { path: '/login', component: Login },
    { path: '/register', component: Register },
    // detail文章详情页
    { path: '/detail/:id', component: Detail },
    {
      path: '/',
      component: Layout,
      redirect: '/article', // 可以直接在这里写重定向
      children: [
        { path: 'article', component: Article },
        { path: 'collect', component: Collect },
        { path: 'like', component: Like },
        { path: 'user', component: User }
      ]
    }
  ]
})

export default router
